<?php
include('../../includes/classes/core.php');
 

$user_id			= $_SESSION['USERID'];
$warehouseDetid 	= $_REQUEST['id'];
$c_data = date('Y-m-d H:i:s');

mysql_query("UPDATE	`warehouse_detail`
			SET			`warehouse_detail`.`test_count` = `warehouse_detail`.`test_count` + 1
			WHERE		`warehouse_detail`.`id` = '$warehouseDetid'");

$rResult = mysql_query("SELECT   `production`.`name` as `cartridge`,
						         `warehouse_detail`.`barcode`	as `barcode`,
						         CONCAT(`client`.`name`,'(',`client_objects`.`name`, ')') AS `client`,
						         CONCAT(`client`.`name`,'(',`client_objects`.`name`, ')') AS `client`,
								 CASE	WHEN NOT ISNULL( `warehouse`.`a_letter_id` ) THEN CONCAT( '№: ა-',`warehouse`.`a_letter_id`)
											WHEN NOT ISNULL( `warehouse`.`d_letter_id` ) THEN CONCAT( '№: დ-',`warehouse`.`d_letter_id`)
											ELSE	CONCAT( '№: R-', `warehouse`.`id`)
								 END  `letter`,	
						         `persons`.`name` AS `worker`,
						         `cartridge_parts_type`.`name` AS `c_part`,
						         `printer_parts_type`.`name` AS `p_part`,		
						         `warehouse_producing`.`date` AS `date`,
								 `warehouse`.`d_letter_id` as `d_letter`,
								 `warehouse_detail`.`test_count` as `test_count`
						FROM	 `warehouse`
						LEFT JOIN `warehouse_detail` ON `warehouse_detail`.`warehouse_id` = `warehouse`.`id`
						LEFT JOIN `warehouse_producing` ON `warehouse_producing`.`warehouse_detail_id` = `warehouse_detail`.`id`
						LEFT JOIN `client_objects` ON `client_objects`.`id` = `warehouse`.`client_object_id`
						LEFT JOIN `client` ON `client_objects`.`client_id` = `client`.`id`
						LEFT JOIN `persons` ON `persons`.`id` = `warehouse_producing`.`person_id`
						LEFT JOIN `cartridge_parts_type` ON `cartridge_parts_type`.`id` = `warehouse_producing`.`cartridge_part_id`
						LEFT JOIN `printer_parts_type` ON `printer_parts_type`.`id` = `warehouse_producing`.`printer_part_id`
						LEFT JOIN `production` ON `production`.`id` = `warehouse_detail`.`prod_id`
						WHERE    `warehouse_detail`.`id` = '$warehouseDetid' AND `warehouse_producing`.`date` = (SELECT MAX(`date`) FROM `warehouse_producing` WHERE `warehouse_producing`.`warehouse_detail_id` = '$warehouseDetid')");
$aRow = mysql_fetch_array( $rResult );

$sqlResult = mysql_query("SELECT	persons.`name` as `tester`
						from		persons
						LEFT JOIN	users ON users.person_id = persons.id
						WHERE	users.id = $user_id
						LIMIT 1");
$sqlRow = mysql_fetch_array( $sqlResult );
$part ='';
$letter = $aRow['letter'];
if( $aRow['d_letter'] != '' ){
	$part = $aRow['p_part'];
	if ( mysql_num_rows($rResult) > 1 ){
		while ( $aRow1 = mysql_fetch_array( $rResult ) )
		{
			$part = $part .', '.$aRow1['p_part'];
		}
	}
}else{
	$part = $aRow['c_part'];
	if ( mysql_num_rows($rResult) > 1 ){
		while ( $aRow1 = mysql_fetch_array( $rResult ) )
		{
			$part = $part .', '.$aRow1['c_part'];
		}
	}	
}
	

?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
p
{
    margin: 0;
    padding: 0;
}
</style>
</head>
<body>
<div style="height: 900px;">
<table>
<tr>
	<td style="float: left;width: 450px; font-size:90%; padding-left: 20px;">მოდელი &nbsp;: &nbsp; <div style="font-size:150%; display: inline;"> <?php echo $aRow['cartridge']; ?> </div></td>
	<td style="padding-left: 0px; width: 350px; font-size:90%;padding-left: 20px;">შტრიხკოდი: <div style="font-size:150%; display: inline;"> <?php echo $aRow['barcode']; ?> </div></td>
</tr>
<tr >
	<td style="float: left;font-size:70%;">კლიენტი &nbsp;: &nbsp; <div style="font-size:130%; display: inline;"> <?php echo $aRow['client']; ?> </div></td>
	<td style="padding-left: 0px;font-size:70%;">შეეცვალა : <div style="font-size:130%; display: inline;"> <?php echo $part; ?> </div></td>
</tr>
<tr >
	<td style="float: left; font-size:70%;">ბარათი&nbsp;&nbsp;: &nbsp;<div style="font-size:130%; display: inline;"> <?php echo $letter; ?> </div></td>
	<td style="text-align:left; font-size:70%;">შეცვლის დრო : <div style="font-size:120%; display: inline;"><?php echo $aRow['date']; ?></div></td>
</tr>
<tr>
	<td style="float: left; font-size:70%;">ტესტერი &nbsp;: &nbsp;<div style="font-size:130%; display: inline;"> <?php echo $sqlRow['tester']; ?> </div></td>
	<td style="text-align:left; font-size:70%;">ტესტის დრო&nbsp;&nbsp; :<div style="font-size:120%; display: inline;"> <?php echo $c_data;?> </div></td>
</tr>
<tr>
	<td style="float: left; font-size:70%;">შემკეთებელი &nbsp;: &nbsp;<div style="font-size:130%; display: inline; background-color:#E7EAE9;"> <?php echo $aRow['worker'].'&nbsp;'; ?> </div></td>
	<td style="text-align:left; font-size:70%;">ტესტ page&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<div style="font-size:120%; display: inline;"> <?php echo  $aRow['test_count'].'&nbsp;';?> </div></td>
	
</tr>
</table>
<table>
	<tr>
		<td>
			<img alt="" style="width: 184px; height: 127px;" src="Untitled-1.png">
		</td>
		<td style="padding-left: 30px; vertical-align: text-top;text-align: center;">
			<img alt="" style="width: 231px; height: 70px;" src="Untitled-2.png">		
		</td>
		<td style="padding-left: 30px;">
			<img alt="" style="width: 184px; height: 127px;" src="Untitled-3.png">
		</td>		
	</tr>
	<tr>
		<td colspan="3" style="text-align: center;">
				<div style="font-size:10;">8 - a b c d e f g h I j k l m n o p q r s t u v w x y z</div>
				<div style="font-size:12;">9 - a b c d e f g h I j k l m n o p q r s t u v w x y z</div>
				<div style="font-size:14;">10 - a b c d e f g h I j k l m n o p q r s t u v w x y z</div>
				<div style="font-size:16;">11 - a b c d e f g h I j k l m n o p q r s t u v w x y z</div>
				<div style="font-size:18;">12 - a b c d e f g h I j k l m n o p q r s t u v w x y z</div>
				<div style="font-size:20;">14 - a b c d e f g h I j k l m n o p q r s t u v w x y z</div>	
		</td>	
	</tr>
	<tr>
		<td colspan="3" style="text-align: center;">
			<img alt="" style="width: 721px; height: 122px;" src="Untitled-6.png">
		</td>	
	</tr>
	<tr>
		<td colspan="3" style="text-align: center;">
			<div style="font-size:10; display: inline;">1 2 3 4 5 6 7 8 9 0 ` ~ ! @ # $ % ^ & * ( ) _ +</div>
			<div style="font-size:14; display: inline;">1 </div>	
			<div style="font-size:11; display: inline;">2 3 4 5 6 7 8 9 0 ` ~ ! @ # $ % ^ & * ( ) _ +</div>		
			<div style="font-size:16; display: inline;">1 </div>	
			<div style="font-size:12; display: inline;">2 3 4 5 6 7 8 9 0 ` ~ ! @ # $ % ^ & * ( ) _ +</div>
			<div style="font-size:13; display: inline;">1 </div><br/>
			<div style="font-size:13; display: inline;">2 3 4 5 6 7 8 9 0 ` ~ ! @ # $ % ^ & * ( ) _ +</div>
			<div style="font-size:13; display: inline;">1 2 3 4 5 6 7 8 9 0 ` ~ ! @ # $ % ^ & * ( ) _ +</div>		
		</td>	
	</tr>
	<tr style="">
		<td colspan="3" style="text-align: center;padding-top: 2px;">
			<img alt="" style="width: 721px; height: 199px;" src="Untitled-8.png">	
		</td>	
	</tr>
	<tr>
		<td colspan="3" style="padding-top: 2px; ">
				<div style="font-size:10;">8 - ა ბ გ დ ე ვ ზ თ ი კ ლ მ ნ ო პ ჟ რ ს ტ უ ფ ქ ღ ყ შ ჩ ც ძ წ ჭ ხ ჯ ჰ - ა ბ გ დ ე ვ ზ თ ი კ ლ მ ნ ო პ ჟ რ ს ტ უ ფ ქ ღ ყ შ ჩ ც ძ წ ჭ ხ ჯ ჰ ა ბ გ დ ე ვ ზ თ ი კ ლ მ </div>
				<div style="font-size:12;">9 - ა ბ გ დ ე ვ ზ თ ი კ ლ მ ნ ო პ ჟ რ ს ტ უ ფ ქ ღ ყ შ ჩ ც ძ წ ჭ ხ ჯ ჰ - ა ბ გ დ ე ვ ზ თ ი კ ლ მ ნ ო პ ჟ რ ს ტ უ ფ ქ ღ ყ შ ჩ ც ძ წ ჭ ხ ჯ ჰ ძ წ ჭ</div>
				<div style="font-size:14;">10 - ა ბ გ დ ე ვ ზ თ ი კ ლ მ ნ ო პ ჟ რ ს ტ უ ფ ქ ღ ყ შ ჩ ც ძ წ ჭ ხ ჯ ჰ ა ბ გ დ ე ვ ზ თ ი კ ლ მ ნ ო პ ჟ რ ს ტ უ ფ  ქ ღ </div>
				<div style="font-size:15;">11 - ა ბ გ დ ე ვ ზ თ ი კ ლ მ ნ ო პ ჟ რ ს ტ უ ფ ქ ღ ყ შ ჩ ც ძ წ ჭ ხ ჯ ჰ ა ბ გ დ ე ვ ზ თ ი კ ლ მ ნ ო პ ჟ რ ს ტ უ </div>
				<div style="font-size:16;">12 - ა ბ გ დ ე ვ ზ თ ი კ ლ მ ნ ო პ ჟ რ ს ტ უ ფ ქ ღ ყ შ ჩ ც ძ წ ჭ ხ ჯ ჰ ა ბ გ დ ე ვ ზ თ ი კ ლ მ ნ ო პ ჟ რ ს</div>
				<div style="font-size:18;">14 - ა ბ გ დ ე ვ ზ თ ი კ ლ მ ნ ო პ ჟ რ ს ტ უ ფ ქ ღ ყ შ ჩ ც ძ წ ჭ ხ ჯ ჰ ა ბ გ დ ე ვ ზ თ  ი კ </div>				
		</td>	
	</tr>
	<tr>
		<td colspan="3" style="padding-top: 2px;">
			<img alt="" style="width: 721px; height: 120px;" src="Untitled-10.png">	
		</td>		
	</tr>				
</table>
</div>
</body>